<template>
	<uni-popup ref="pop_pay2">
		<view class="pay2">
			<view class="black_1">
				<view class="title">兑换</view>
				<image @click="close()" class="img" src="../../static/my/close.png"></image>
			</view>
			<view class="black_2">
				兑换数量
			</view>
			<uni-easyinput
			class="inputs"
			type="digit" 
			v-model="num" 
			:inputBorder="false" 
			:styles="{backgroundColor: '#FFE6D5'}"
			placeholder="请输入兑换数量"
			placeholder-style="color:#FE903D;font-size:16px"
			></uni-easyinput>
			
			<view class="black_2 black_3">
				当前1QWB≈{{qwb.qwb_u_value}}USDT
			</view>
		<!-- 	<uni-easyinput
			class="inputs"
			type="dist" 
			v-model="num" 
			:inputBorder="false" 
			:styles="{backgroundColor: '#FFE6D5'}"
			:placeholder="placeholder"
			placeholder-style="color:#FE903D;font-size:16px"
			></uni-easyinput> -->
			
			
			<uni-easyinput
			class="inputs inputs2"
			type="password" 
			v-model="password" 
			:inputBorder="false" 
			:styles="{backgroundColor: 'transparent'}"
			placeholder="请输入支付密码"
			placeholder-style="color:#FE903D;font-size:16px"
			></uni-easyinput>
			
			<view class="black_4" v-if="num">
				<!-- 扣取转赠手续费<text class="text1">5%</text> -->
				本次兑换将扣除 {{Number(num)*qwb.qwb_exchange_info.usdt}}USDT+{{Number(num)*qwb.qwb_exchange_info.gasoline}}汽油+{{Number(num)*qwb.qwb_exchange_info.debris}}个汽车碎片
			</view>
			
			<view class="black_5" >
				<view class="text1" @click="submit()">确定兑换</view>
			</view>
		</view>
	</uni-popup>
		
</template>

<script>
	export default {
		props:{
			success:{
				type:Function,
			}
		},
		name:"pay2",
		data() {
			return {
				ids:'',
				num:'',
				password:'',
				account_type:'',
				placeholder:'请输入数量',
				// qwb:null,
				 "qwb": {
				            "qwb_u_value": "71.63",
				            "count_qwb_num": "100000",
				            "qwb_exchange_info": {
				                "usdt": "20",
				                "gasoline": "100",
				                "debris": "10"
				            },
				            "qwb_issue_rule": "1.发行10w USDT<br>\r\n2.发行10w USDT <br>\r\n3.发行10w USDT<br>\r\n4.发行10w USDT"
				        }
			};
		},
		methods:{
			open(qwb){
				this.qwb = qwb
				this.$refs.pop_pay2.open()
			},close(){
				this.$refs.pop_pay2.close()
			
			},
			getNum(){
				
			},
			submit(){
				if(!this.password){
					uni.showToast({
						title: "请输入密码",
						icon: "none"
					})
					return
				}
				if(!this.num){
					uni.showToast({
						title: "请输入数量",
						icon: "none"
					})
					return
				}
				
				var gasoline = Number(this.qwb.qwb_exchange_info.gasoline)
				var debris = Number(this.qwb.qwb_exchange_info.debris)
				var usdt = Number(this.qwb.qwb_exchange_info.usdt)
				var num = Number(this.num)
				var num1 = num*usdt + num*gasoline+num*debris
				var data={
					num:num1,
					pay_password:this.password
				}
				this.api.http.requests('accountlog/exchange', data, res => {
					// console.log(res)
					uni.showToast({
						title: res.msg,
						icon: "none"
					})
					this.success()
					this.close()
				}, "POST")
			}
		}
	}
</script>

<style scoped lang="less">
	
.pay2{
	background: linear-gradient(180deg, #FFE6D5 0%, #FFFFFF 100%);
	border-radius: 12px 12px 12px 12px;
	border-radius: 5px;
	padding: 20px;
	width: 600upx;
	// width: 100%;
	height: auto;
}
.black_1{
	text-align: center;
	font-size: 27px;
	font-weight: 800;
	color: #333333;
	width: 100%;
	.img{
		width: 25px;
		height: 25px;
		position: absolute;
		right: 10px;
		top: 10px;
	}
}
.black_2{
	margin-top: 20px;
	font-size: 18px;
	font-weight: 800;
	color: #333333;
}
.black_3{
	font-size: 25rpx;
	font-weight: 400;
	color: #333333;
}
.inputs{
		margin-top: 10px;
		padding: 5px 0px;
		border: 1px solid #FFE6D5;
		border-radius: 5px;
		font-size: 30rpx;
		font-weight: 400;
		background-color: #FFE6D5;
		// text-align: end;
	}
	.inputs2{
		margin:40px auto 10px auto;
		width: 250px;
		border-radius: 20px;
		text-align: center;
	}
	.black_4{
		text-align: center;
		font-size: 14px;
		font-weight: 400;
		color: #FF2D2D;
		// .text1{
		// 	margin-left: 5px;
		// 	color: #FE903D;
		// }
	}
	
	.black_5{
		margin: 40px auto 10px auto;
		width: 146px;
		height: 45px;
		line-height: 45px;
		color: white;
		text-align: center;
		background: #FE903D;
		border-radius: 10px 10px 10px 10px;
	}
</style>